import React, {Component} from 'react'
import {connect} from 'react-redux'
import { Route } from 'react-router'
import { dispatchMessage } from '../state/action'
import ChildRoutes from '../../../route/index'

class List extends Component {
	constructor(props) {
		super(props);
        this.state = {
            route: []
        }
        this.dispatchMessage = this.props.dispatchMessage
	}

	componentWillMount = () => {
        let path = this.props.match.path
        this.setState({
            route: ChildRoutes.find(item => item.path === path)
        })
        this.dispatchMessage('sleep123')
	}

	render() {
        console.log(this.props)
		return (
            <div>This is list Component, is Worked!
                {/* {
                    this.state.route.map(item => {
                        return (<Route path=`${this.prop.match}/item.path`></Route>)
                    })
                } */}
            </div>
        )
	}
}

function mapStateToProps(state) {
	return {value: state.count}
}
export default connect(mapStateToProps, {
    dispatchMessage
})(List)
